package com.sunthy.mall.utils;

import com.sunthy.mall.service.admin.admin.AdminServiceImpl;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @Description:
 * @Author: XM
 */
public class MybatisUtils {
    private static SqlSessionFactory factory;

    static {
        InputStream inputStream = AdminServiceImpl.class.getClassLoader().getResourceAsStream("mybatis.xml");
        factory = new SqlSessionFactoryBuilder().build(inputStream);
    }

    public static SqlSession openSession(){
        return factory.openSession();
    }
}
